﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel.Composition;
using System.Data.Linq.Mapping;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(IProductVariation))]
    public partial class ProductVariation : Entity, IProductVariation
    {



        #region IProductVariation Members

        IVariation _Variation;
        IVariation IProductVariation.Variation
        {
            get
            {
                if (this._Variation == null)
                {
                    this._Variation = this.DataContext.ProductAttributes
                        .Where(i => i.Id == this.VariationId)
                        .FirstOrDefault();
                }

                return this._Variation;
            }
            set
            {
                this._Variation = value;
                this.VariationId = value.Id;
            }
        }


        //only for query
        //[global::System.Data.Linq.Mapping.AssociationAttribute(Name = "ProductAttribute_ProductVariation", Storage = "_ProductAttribute", ThisKey = "VariationId", OtherKey = "Id", IsForeignKey = true)]
        //[ColumnAttribute(IsDbGenerated = false, AutoSync = AutoSync.Never, UpdateCheck = UpdateCheck.Never)]
        //public ProductAttribute Variation
        //{
        //    get;
        //    set;
        //}

        #endregion
    }
}
